function [f, d, pos] = extractOverlayBlock2( img, B)
if nargin < 2
    B = 64;
end
B2 = floor(B / 2);
clear f  d  pos;
[M, N, S] = size(img);
L = 0;
gray = rgb2gray(img);
scaled = double(gray / 256);
for i = 1:B2:M-B+1
    i1 = floor(i / B2) + 1;
    for j = 1:B2:N-B+1
        j1 = floor(j / B2) + 1;
        block = scaled(i:i+B-1,j:j+B-1,:);
        [fz, dz] = sift(block);
        f{i1, j1} = fz;
        d{i1, j1} = dz;
        pos{i1, j1} = [i i+B-1 j j+B-1];
    end
end
end
